var url="";
var model;
var request;
var Leng;
var result=false;
function LoadData(){
result=false;
    request.post('http://'+url+'/app/Chiller!view.action?id='+GetQueryString('id')+'&projectId='+GetQueryString('projectId')).success(function(data){
        // if(data!=null&&data.length==0){
        //    $("#body").html("<div style='margin:100px auto;width:200px;height:100px;position: relative;text-align:center;'><img  style='position: relative;' src='image/nodata.png' width='62' height='66'/><br/><span style='font-size:14px;color:rgb(141,141,141);'>没有相关内容!</span></div>");
        //  }else
        //  {
        //  }
        console.log(data);
        model.detail=data;

        var colors = data.copLevels.split(",");
        model.cop1 = {'width':colors[0]+'%'};
        model.cop2 = {'width':colors[1]+'%'};
        model.cop3 = {'width':colors[2]+'%'};
        model.cop4 = {'width':colors[3]+'%'};
         var dds = model.getcalColor2(colors[0],colors[1],colors[2],colors[3],data.cop);
             model.coppostion = {
        'left': window.innerWidth * 0.84 * (data.cop/10)-9.5 +'px'
         };
         model.cop5 = {'color':dds};
         result=true;
         }).error(function(data,status,headers,config){
      if((status>=200&&status<300)||status===304||status===1223||status===0){
      $("body").html("网络访问出错！");
      }
      });
}

(function(){
	var app=angular.module('Leng',[ ]);
	app.controller('LengController',['$http','$window',function($http,$window){
     Leng=this;
		request=$http;
    model=Leng;
    url='120.26.110.125/jncloud';
    Leng.index = GetQueryString('index');
    bindEvent();
    LoadData();


    Leng.getcalColor2=function(a,b,c,d,e)
    {
         var d1 = Number(d);
         var a1 = Number(a);
         var b1 = Number(b);
         var c1 = Number(c);
         var e1 = Number(e)*10;
         if(e1<=a1) {Leng.copjpg = 'arr1.png';return '#33b24b';} 
         else if(e1>a1&&e1<=(a1+b1)) {
           Leng.copjpg = 'arr2.png';
          return '#ffcc00';
         }
         else if(e1>(a1+b1)&&e1<=(a1+b1+c1)) {
           Leng.copjpg = 'arr3.png';
          return '#ff333b';
         } 
         else if(e1>(a1+b1+c1)&&e<=(a1+b1+c1+d1)){
           Leng.copjpg = 'arr4.png';
           return '#5cc9ff';
         } 

    }

    Leng.copjpg = 'arr2.png';
    Leng.cop5 = {'color':'#33b24b'}


	}]);
})();
